import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import './assets/fonts/iconfont.css'
import './assets/css/global.css'
import axios from 'axios'
import TreeTable from 'vue-table-with-tree-grid'
// 富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
// 富文本对应的样式
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme

import NProgress from 'nprogress'
import'nprogress/nprogress.css'

Vue.config.productionTip = false
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
// request拦截器，进度条开始
axios.interceptors.request.use(config => {
  NProgress.start();
  config.headers.Authorization = window.sessionStorage.getItem('token');
  return config;
})
// response拦截器，进度条结束
axios.interceptors.response.use(config => {
  NProgress.done();
  return config;
});
Vue.prototype.$http = axios

Vue.component('tree-table', TreeTable);

Vue.use(VueQuillEditor);

Vue.filter('dateFormat', function (val) {
  const dt = new Date(val);
  const year = dt.getFullYear()
  const month = (dt.getMonth() + '').padStart(2, '0');
  const day = (dt.getDate() + '').padStart(2, '0');
  const hour = (dt.getHours() + '').padStart(2, '0');
  const minute = (dt.getMinutes() + '').padStart(2, '0');
  const second = (dt.getSeconds() + '').padStart(2, '0');
  return `${year}-${month}-${day} ${hour}:${minute}:${second}`
})

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
